﻿#region Header

//Sample license text.

#endregion Header

namespace Probel.AspTest.Controllers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;

    using Probel.AspTest.Domain;
    using Probel.AspTest.Domain.Components;
    using Probel.AspTest.Models;

    public class HomeController : Controller
    {
        #region Fields

        private readonly IHomeComponent Component = ComponentFactory.New<IHomeComponent>();

        #endregion Fields

        #region Methods

        public ActionResult About()
        {
            return View();
        }

        /// <summary>
        /// Any argument passed to a controler is done via the url
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            ViewBag.Message = "nDoctor statistics";
            var model = new HomeModel()
            {
                UserCount = this.Component.CountUsers(),
                FirstInstallation = this.Component.GetFirstInstallation(),
                LastInstallation = this.Component.GetLastInstallation(),
                StatCount = this.Component.CountStatistics(),
                LastUpdate = this.Component.GetLastUpdate(),
            };

            return View(model);
        }

        #endregion Methods
    }
}